import * as actionTypes from './actionTypes'
import { fromJS } from 'immutable'
const defaultState = fromJS({
  topicList: [],
  articleList:[],
  recommendList: [],
  acticlePage: 1,
  showBottom: false
})

export default (state = defaultState, action) => {
  console.log('首页reducer')
  switch(action.type){
    case actionTypes.CHANGE_HOME_LIST:
      return state.merge({
        topicList: fromJS(action.data.topList),
        articleList: fromJS(action.data.articleList),
        recommendList: fromJS(action.data.recommendList)
      })
    case actionTypes.ADD_ACTICLELIST:
      return state.merge({
        'articleList': state.get('articleList').concat(fromJS(action.data)),
        'acticlePage': action.page
      })
    case actionTypes.SHOW_TOGGLE:
      return state.set('showBottom', action.show)
    default:
      return state;
  }
}